import java.util.LinkedList;
import java.util.List;

public class binary_tree_preorder_traversal {
    //递归遍历
    public List<Integer> preorderTraversal(TreeNode root) {
        List<Integer> res=new LinkedList<>();
        preOrder(root,res);
        return res;
    }

    public  void  preOrder(TreeNode root,List<Integer> res){
        if(root==null) return ;
        res.add(root.val);
        preOrder(root.left,res);
        preOrder(root.right,res);
    }


}
